package com.zhupf.binaryTree;

/**
 * @author zhupf
 * @date 2023年11月24日 14:51
 * @Description
 *
 * 226. 翻转二叉树
 */
public class InvertTree {

    public TreeNode invertTree(TreeNode root) {
        TreeNode tree = root;
        reserve(tree);
        return root;
    }

    private void reserve(TreeNode root){
        if(root == null){
             return;
        }
        reserve(root.left);
        reserve(root.right);
        TreeNode tmp =  root.left;
        root.left = root.right;
        root.right = tmp;
    }

}
